home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / ANC_UTULITYS_16.adf / arclist / asm2.arc / ten3.S < prev    next >
Text File  |  1988-09-21  |  9KB  |  387 lines

  1.  
  2. beg:                    ; As usual...
  3. movem.l    d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6,-(a7)
  4. move.l    a7,InitialSP            ; Just to be on the safe side
  5. bsr    SwitchOSout            ; Switch out Operating System
  6. bsr    Initchips            ; Setup Custom chip pointers
  7. bsr    Initint                ; Setup Interrupts.
  8. bsr    InitOther            ; Init the other stuff
  9. bsr    Wait                ; Handle input stuff
  10. bsr    Resetint            ; Reset interrupts
  11. bsr    Resetchips            ; Reset custom chips
  12. bsr    SwitchOSin            ; Switch in Operating System.
  13. move.l    InitialSP,a7            ; Restore Stack Frame Pointer
  14. movem.l    (a7)+,a0/a1/a2/a3/a4/a5/a6/d0/d1/d2/d3/d4/d5/d6/d7
  15. rts
  16.  
  17. InitialSP:dc.l 0            ; Hold initial SP
  18.  
  19. SwitchOSout:                ; Switch out disturbing stuff.
  20. move.l    $4,a6                ; System Base
  21. lea    gfxlib,a1
  22. clr.l    d0
  23. jsr    -552(a6)            ; _LVOOpenLibrary
  24. move.l    d0,gfxbase            ; Save Graphics_lib base
  25. jsr    -$84(a6)            ; _LVOForbid
  26. jsr    -$96(a6)            ; _LVOSuperState
  27. move.l    d0,systack            ; System stack
  28. rts
  29.  
  30. systack:dc.l 0
  31. gfxlib:dc "graphics.library",0,0
  32. gfxbase:dc.l 0
  33.  
  34. Initchips:                ; Initialize custom chips
  35. move.w    $dff01c,intesave
  36. move.w    $dff01e,intrsave
  37. move.w    $dff002,dmasave
  38. move.w    $dff010,adksave
  39. move.w    #%0111111111111111,$dff096    ; DMACONW
  40. move.w    #%1000001111100000,$dff096    ; Disable disk access.
  41. move.w    #%0111111111111111,$dff09a    ; INTENA
  42. move.w    #%1100000000110100,$dff09a    ; Enable desired IRQ's
  43. move.l    #copl,$dff080
  44. rts
  45.  
  46. intesave:dc.w    0
  47. intrsave:dc.w    0
  48. dmasave:dc.w    0
  49. adksave:dc.w    0
  50.  
  51. InitInt:                ; Initialize interrupts
  52. move.l    $6c,level3save            ; Save level 3 vector
  53. move.l    $6c,af3+2
  54. move.l    $68,level2save            ; Save level 2 vector
  55. move.l    $68,af2+2
  56. move.l    #level2irq,$68            ; Set new interrupt vector 2
  57. move.l    #level3irq,$6c            ; Set new interrupt vector 3
  58. rts
  59.  
  60. level2save:dc.l 0
  61. level3save:dc.l 0
  62.  
  63. ResetInt:                ; Reset Interrupts
  64. move.l    level3save,$6c            ; Restore level 3 vector
  65. move.l    level2save,$68            ; Restore level 2 vector
  66. rts
  67.  
  68. Resetchips:                ; Reset custom chips
  69. move.w    intesave,d7
  70. bset    #$f,d7
  71. move.w    d7,$dff09a            ; Reset Interrupts
  72. move.w    intrsave,d7
  73. bset    #$f,d7
  74. move.w    d7,$dff09c            ; Reset interrupt request
  75. move.w    dmasave,d7
  76. bset    #$f,d7
  77. move.w    d7,$dff096            ; Reset DMAConw
  78. move.w    adksave,d7
  79. bset    #$f,d7
  80. move.w    d7,$dff09e            ; Reset ADK
  81. move.l    gfxbase,a0
  82. move.l    $26(a0),$dff080
  83. rts
  84.  
  85. SwitchOSIn:                ; Allow OS to operate again.
  86. move.l    4,a6                ; System Base
  87. jsr    -$8a(a6)            ; _LVOPermit
  88. move.l    systack,d0            ; Systemstack
  89. jsr    -$9c(a6)            ; _LVOUserState
  90. rts
  91.  
  92. level2irq:
  93. af2:jmp 0
  94.  
  95. level3irq:
  96. movem.l    d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6,-(a7)
  97. ;move.w    #$000f,$dff180
  98. movem.l    (a7)+,d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6
  99. af3:jmp 0
  100.  
  101. rotdly:dc.w 250
  102. rotdirection:dc.w 0
  103. rotate:dc.w 0
  104.  
  105. dorotation:
  106. tst.w    rotate
  107. bne.s    rotatin
  108.  
  109. subq.w    #1,rotdly
  110. bne.s    norot
  111.  
  112. move.w    #150,rotate
  113.  
  114. rotatin:
  115. subq.w    #1,rotate
  116. beq.s    norot3
  117.  
  118. tst.w    rotdirection
  119. bne.s    other
  120.  
  121. lea    dire,a0
  122. moveq    #99,d6
  123. slp:
  124. move.w    (a0),d0
  125. addq.w    #2,d0
  126. cmpi.w    #720,d0
  127. blt.s    nomore
  128. subi.w    #720,d0
  129. nomore:
  130. move.w    d0,(a0)+
  131. dbf    d6,slp
  132. bra.s    norot2
  133.  
  134. other:
  135. lea    dire,a0
  136. moveq    #99,d6
  137. slp2:
  138. move.w    (a0),d0
  139. subq.w    #2,d0
  140. cmpi.w    #0,d0
  141. bge.s    nomore2
  142. addi.w    #720,d0
  143. nomore2:
  144. move.w    d0,(a0)+
  145. dbf    d6,slp2
  146. bra.s    norot2
  147.  
  148. norot3:
  149. eor.w    #$ffff,rotdirection
  150. move.w    #250,rotdly
  151. norot2:
  152.  
  153. norot:
  154. rts
  155.  
  156. initother:
  157. lea    $60000,a0
  158. move.w    #$2bff,d0
  159. clp:
  160. clr.l    (a0)+
  161. dbf    d0,clp
  162. rts
  163.  
  164. Wait:                    ; Wait.
  165. bsr    dostars
  166. bsr    dorotation
  167. btst    #6,$bfe001
  168. bne.s    wait
  169. rts
  170.  
  171. dostars:
  172. moveq    #0,d3
  173. moveq    #99,d2
  174. lea    $60000,a0            ; Bpl 1
  175. lea    $62c00,a1            ; Bpl 2
  176. lea    sine,a6                ; Sine table
  177. lea    posx,a5                ; X pos table
  178. lea    posy,a4                ; Y pos table
  179. lea    dire,a3                ; Direction table
  180.  
  181. thelot:
  182. moveq    #0,d0
  183. move.w    (a5),d0                ; Xpos * 100
  184. move.w    (a4),d1                ; Ypos * 100
  185. move.w    (a3)+,d7            ; Direction (angle * 2)
  186. move.w    d7,d6
  187. add.w    #180,d6                ; Y direction
  188. cmpi.w    #720,d6
  189. blt.s    notnow
  190. subi.w    #720,d6                ; cos(360)=cos(0)
  191. notnow:
  192.  
  193. movem.l    d0/d1/d3,-(a7)
  194. divu    #100,d0
  195. divu    #100,d1
  196. mulu    #44,d1
  197. move.w    d0,d3
  198. asr.w    #3,d3
  199. not.b    d0                ; DELETE OLD STAR
  200. andi.w    #7,d0
  201. add.l    d3,d1
  202. bclr    d0,0(a0,d1)
  203. bclr    d0,0(a1,d1)
  204. lea    $2c00(a1),a1
  205. bclr    d0,0(a1,d1)
  206. lea    -$2c00(a1),a1
  207. movem.l    (a7)+,d0/d1/d3
  208.  
  209. move.l    d7,-(a7)
  210. move.w    (a6,d7.w),d5            ; Get sine value
  211. move.w    (a6,d6.w),d4            ; Get cosine value
  212. move.w    198(a3),d7
  213. divu    #10,d7
  214. addq.w    #1,d7
  215. muls    d7,d4
  216. muls    d7,d5                ; Star gets faster nearer edge
  217. divs    #5,d4
  218. divs    #5,d5
  219. move.l    (a7)+,d7
  220.  
  221. add.w    d5,d0                ; Xpos
  222. add.w    d4,d1                ; Ypos
  223. move.w    d0,(a5)+            ; Xpos save
  224. move.w    d1,(a4)+            ; YPos save
  225. divu    #100,d0                ; Xpos = Xpos/100 = Xpos
  226. divu    #100,d1                ; Ypos = Ypos/100 = Ypos
  227. cmpi.w    #352,d0
  228. bge.s    res
  229. cmpi.w    #0,d0
  230. blt.s    res
  231. cmpi.w    #256,d1
  232. bge.s    res
  233. cmpi.w    #0,d1
  234. bge.s    nores
  235. res:
  236. move.w    #176,d0
  237. move.w    #17600,-2(a5)            ; Save the pos'n
  238. move.w    #127,d1
  239. move.w    #12700,-2(a4)
  240. clr.w    198(a3)                ; Clear nummoves
  241. nores:
  242. addq.w    #1,198(a3)
  243.                     ; SETDOT
  244. move.l    d7,-(a7)
  245. mulu    #44,d1
  246. move.w    d0,d3
  247. asr.w    #3,d3                ; Divide by 8
  248. add.l    d3,d1
  249. not.b    d0
  250. andi.w    #7,d0
  251.  
  252. move.w    198(a3),d7
  253. asr.w    #4,d7
  254. addq.b    #1,d7
  255. cmpi.b    #7,d7
  256. ble.s    nofix
  257. moveq    #7,d7
  258. nofix:
  259. asr.b    #1,d7
  260. bcc.s    nopl1
  261. bset    d0,0(a0,d1)            ; Set point
  262. nopl1:
  263. asr.b    #1,d7
  264. bcc.s    nopl2
  265. bset    d0,0(a1,d1)
  266. nopl2:
  267. asr.b    #1,d7
  268. bcc.s    nopl3
  269. lea    $2c00(a1),a1
  270. bset    d0,(a1,d1)
  271. lea    -$2c00(a1),a1
  272. nopl3:
  273.  
  274. move.l    (a7)+,d7
  275.  
  276. dbf    d2,thelot
  277. rts
  278.  
  279. posx:
  280. dc.w    11600,01600,22600,03600,14600,12600,09600,29600,08600,01600
  281. dc.w    17600
  282. dc.w    27600,13600,19600,08600,05600,04600,11600,21600,31600,34600
  283. dc.w    17600
  284. dc.w    17600,15600,17600,15400,24300,30600,35000,11700,02500,17600
  285. dc.w    17600
  286. dc.w    17600,07600,03600,14600,12100,12600,13600,19600,11600,10600
  287. dc.w    17600
  288. dc.w    27100,17600,17600,26600,24600,29100,17600,31600,17600,17600
  289. dc.w    11600
  290. dc.w    19600,17600,22600,17600,27600,12600,11600,19600,13600,11200
  291. dc.w    24600
  292. dc.w    09600,17500,22100,17600,27600,17600,17600,12100,11900,22900
  293. dc.w    12600
  294. dc.w    09600,27600,22600,17600,27600,17600,15600,11600,19600,17600
  295. dc.w    24600
  296. dc.w    19600,17600,22600,15600,27600,17600,07600,09600,02600,31600
  297. dc.w    04600
  298. dc.w    19600,17600,22600,17600,27600,17600,15600,18500,17600,01600
  299. dc.w    14600
  300.  
  301. posy:
  302. dc.w    12700,12700,12700,12700,12700,12700,12700,12700,12700,12700
  303. dc.w    12700
  304. dc.w    12700,12700,12700,12700,12700,12700,12700,12700,12700,12700
  305. dc.w    12700
  306. dc.w    12700,02700,13700,14700,15700,16700,17700,18700,19700,12700
  307. dc.w    12700
  308. dc.w    02700,10700,19700,12700,12700,14700,12700,15400,12700,12700
  309. dc.w    12700
  310. dc.w    22700,16700,10700,02700,03700,07700,17700,12700,12700,12700
  311. dc.w    14700
  312. dc.w    19700,12700,16700,12700,12700,12700,12700,12700,12700,12700
  313. dc.w    18700
  314. dc.w    10700,16700,12700,12700,12700,12700,12700,12700,12700,12700
  315. dc.w    12700
  316. dc.w    18700,12700,12700,12700,12700,12700,12700,12700,12700,12700
  317. dc.w    12700
  318. dc.w    16700,17700,12700,12700,12700,12700,12700,12700,12700,12700
  319. dc.w    12700
  320. dc.w    14700,22700,19700,21700,20700,12700,12700,12700,12700,12700
  321. dc.w    12700
  322.  
  323. dire:
  324. dc.w    000,090,180,270,360,450,540,630,044,134
  325. dc.w    006,096,186,276,366,456,546,636,050,140
  326. dc.w    012,102,192,282,372,462,552,642,056,146
  327. dc.w    018,108,198,288,378,468,558,648,062,152
  328. dc.w    024,114,204,294,384,474,564,654,068,156
  329. dc.w    030,120,210,300,390,480,570,660,074,162
  330. dc.w    124,114,204,306,396,474,564,654,268,156
  331. dc.w    130,120,210,312,402,440,570,660,074,162
  332. dc.w    124,114,204,318,408,474,564,654,168,156
  333. dc.w    130,120,210,324,414,680,470,260,474,262
  334. nummoves:
  335. blk.w    100,0
  336.  
  337. copl:
  338. dc.w $0100,$3200
  339. dc.w $00e0,$0006,$00e2,$0000
  340. dc.w $00e4,$0006,$00e6,$2c00
  341. dc.w $00e8,$0006,$00ea,$5800
  342. dc.w $0102,$0000,$0104,$0030,$008e,$2480
  343. dc.w $0090,$24e0,$0092,$0030,$0094,$00d8
  344. dc.w $010a,$0000,$0108,$0000,$0120,$0000
  345. dc.w $0122,$0000
  346. dc.w $0182,$0444,$0184,$0555,$0186,$0777,$0188,$0999
  347. dc.w $018a,$0aaa,$018c,$0bbb,$018e,$0ccc
  348. dc.w $0124,$0000,$0126,$0000,$0128,$0000,$012a,$0000
  349. dc.w $012c,$0000,$012e,$0000,$0130,$0000,$0132,$0000
  350. dc.w $0134,$0000,$0136,$0000,$0138,$0000,$013a,$0000
  351. dc.w $013c,$0000,$013e,$0000
  352. dc.w $0180,$0000
  353. dc.w $ffff,$fffe
  354.  
  355. sine:
  356. dc.w  0, 2, 6, 10, 12, 16,20, 24, 26, 30, 34, 38
  357. dc.w  40, 44, 48, 50, 54, 58,60, 64, 68, 70, 74, 78
  358. dc.w  80, 84, 86, 90, 92, 96,100, 102, 104, 108, 110, 114
  359. dc.w  116, 120, 122, 124, 128, 130, 132, 136, 138, 140, 142, 146
  360. dc.w  148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170
  361. dc.w  172, 174, 176, 178, 178, 180, 182, 184, 184, 186, 186, 188
  362. dc.w  190, 190, 192, 192, 194, 194, 194, 196, 196, 196, 198, 198
  363. dc.w  198, 198, 198, 198, 198, 198, 200, 198, 198, 198, 198, 198
  364. dc.w  198, 198, 198, 196, 196, 196, 194, 194, 194, 192, 192, 190
  365. dc.w  190, 188, 186, 186, 184, 184, 182, 180, 178, 178, 176, 174
  366. dc.w  172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150
  367. dc.w  148, 146, 142, 140, 138, 136, 132, 130, 128, 124, 122, 120
  368. dc.w  116, 114, 110, 108, 104, 102, 98, 96, 92, 90, 86, 84
  369. dc.w  80, 78, 74, 70, 68, 64, 60, 58, 54, 50, 48, 44
  370. dc.w  40, 38, 34, 30, 26, 24, 20, 16, 12, 10, 6, 2
  371. dc.w -2,-4,-8,-12,-14,-18,-22,-26,-28,-32,-36,-40
  372. dc.w -42,-46,-50,-52,-56,-60,-62,-66,-70,-72,-76,-80
  373. dc.w -82,-86,-88,-92,-94,-98,-102,-104,-106,-110,-112,-116
  374. dc.w -118,-122,-124,-126,-130,-132,-134,-138,-140,-142,-144,-148
  375. dc.w -150,-152,-154,-156,-158,-160,-162,-164,-166,-168,-170,-172
  376. dc.w -174,-176,-178,-180,-180,-182,-184,-186,-186,-188,-188,-190
  377. dc.w -192,-192,-194,-194,-196,-196,-196,-198,-198,-198,-200,-200
  378. dc.w -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200
  379. dc.w -200,-200,-200,-198,-198,-198,-196,-196,-196,-194,-194,-192
  380. dc.w -192,-190,-188,-188,-186,-186,-184,-182,-180,-180,-178,-176
  381. dc.w -174,-172,-170,-168,-166,-164,-162,-160,-158,-156,-154,-152
  382. dc.w -150,-148,-144,-142,-140,-138,-134,-132,-130,-126,-124,-122
  383. dc.w -118,-116,-112,-110,-106,-104,-100,-98,-94,-92,-88,-86
  384. dc.w -82,-80,-76,-72,-70,-66,-62,-60,-56,-52,-50,-46
  385. dc.w -42,-40,-36,-32,-28,-26,-22,-18,-14,-12,-8,-4
  386. end:
  387.